<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ok</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  2</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  4</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">connection</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">SQLite</span><span class="PUNC">(</span><span class="STRN">"db.sqlite"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="WHIT">	</span><span class="NAME">ok</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">		</span><span class="WHIT">
<span class='line'>  6</span> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  7</span> </span><span class="WHIT">	</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Databa file missing. \n Please at the directory: C:/\Program Files/\Mozilla Thunderbird/\chrome give"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="WHIT">		</span><span class="STRN">" full acces to your user name. "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  9</span> </span><span class="WHIT">	</span><span class="NAME">ok</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span> 	*@class initTable
<span class='line'> 13</span> 	*@description This function will create the tables for to store the events
<span class='line'> 14</span> 	*
<span class='line'> 15</span> 	*@author Resz Janos
<span class='line'> 16</span> */</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">creatTables</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ok</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">	</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"CREATE TABLE IF NOT EXISTS tb_category (categoryId INTEGER PRIMARY KEY AUTOINCREMENT, categoryName STRING )"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">	</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"CREATE TABLE IF NOT EXISTS tb_reminder (reminderId INTEGER PRIMARY KEY AUTOINCREMENT, remind INTEGER,reminderName STRING )"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT">	</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"CREATE TABLE IF NOT EXISTS tb_repeat (repeatId INTEGER PRIMARY KEY AUTOINCREMENT, repeatName STRING )"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 						</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT">	</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"CREATE TABLE IF NOT EXISTS tb_event (eventId INTEGER PRIMARY KEY AUTOINCREMENT,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">						</span><span class="STRN">"categoryId INTEGER REFERENCES tb_category (categoryId), reminderId INTEGER REFERENCES tb_reminder (reminderId),"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">						</span><span class="STRN">"repeatId INTEGER REFERENCES tb_repeat (repeatId),"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">						</span><span class="STRN">"hour INTEGER,minute INTEGER, name STRING, location STRING, description STRING,year INTEGER, month INTEGER, day INTEGER,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">						</span><span class="STRN">"endYear INTEGER, endMonth INTEGER, endDay INTEGER, endHour INTEGER, endMinute INTEGER,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">						</span><span class="STRN">"remindYear INTEGER, remindMonth INTEGER, remindDay INTEGER,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">						</span><span class="STRN">"remindHour INTEGER, remindMinute INTEGER)"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">			</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Not create tables"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">		</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="COMM">/**
<span class='line'> 38</span> 	*@class initTable
<span class='line'> 39</span> 	*@description This function will delete the tables
<span class='line'> 40</span> 	*
<span class='line'> 41</span> 	*@author Resz Janos
<span class='line'> 42</span> */</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">deleteTables</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 44</span> 
<span class='line'> 45</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ok</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"DROP TABLE IF EXISTS tb_reminder"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"DROP TABLE IF EXISTS tb_repeat"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"DROP TABLE IF EXISTS tb_category"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"DROP TABLE IF EXISTS tb_event"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">		</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Not delete tables"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 58</span> 
<span class='line'> 59</span> </span><span class="COMM">/**
<span class='line'> 60</span> 	*@class initTable
<span class='line'> 61</span> 	*@description This function will init the tables.
<span class='line'> 62</span> 	*
<span class='line'> 63</span> 	*@author Resz Janos
<span class='line'> 64</span> */</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">initTables</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ok</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_reminder (remind,reminderName) VALUES (15,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">							</span><span class="STRN">"'15 minutes before')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_reminder (remind,reminderName) VALUES (30,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">							</span><span class="STRN">"'30 minutes before')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_reminder (remind,reminderName) VALUES (60,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">						   </span><span class="STRN">"'One hour before')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_reminder (remind,reminderName) VALUES (1440,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">						   </span><span class="STRN">"'Before a day')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_reminder (remind,reminderName) VALUES (0,"</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">						   </span><span class="STRN">"'Events given time')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_repeat (repeatName) VALUES ("</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">							</span><span class="STRN">"'Daily')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_repeat (repeatName) VALUES ("</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">							</span><span class="STRN">"'Weekly')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_repeat (repeatName) VALUES ("</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">						   </span><span class="STRN">"'Monthly')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_repeat (repeatName) VALUES ("</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">						   </span><span class="STRN">"'Yearly')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_repeat (repeatName) VALUES ("</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">						   </span><span class="STRN">"'No repeat')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_category (categoryName) VALUES ('Birthday')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_category (categoryName) VALUES ('Name day')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_category (categoryName) VALUES ('Anniversary')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">		</span><span class="NAME">connection.execute</span><span class="PUNC">(</span><span class="STRN">"INSERT INTO tb_category (categoryName) VALUES ('Other')"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">		</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Not init tables"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>100</span> 
<span class='line'>101</span> </span></pre></body></html>